#ifndef LOG_READER
#define LOG_READER
#include "commonHeader.h"

#include <QDomDocument>


enum securityLog{
	Logon = 4624,
	Logoff = 4647,  //User initiated logoff:
	Log_Clear = 1102
};
struct entryInfo{
	entryInfo(){
		dt = QDateTime();
		loginID = 0;
		userName = "";
	}
	entryInfo(QDateTime t, int id, QString user, QString process, QString _hostName, QString Test = ""){
		dt = t;
		loginID = id;
		userName = user;
		processName = process;
		hostName = _hostName;
		test = Test;
	}
	QDateTime dt;
	int loginID;
	QString userName, processName, hostName, test;
};

class myLogReader {
public:
	myLogReader(){}
	bool mainMethod();
private:
	QStringList allQueryStr;
	QList<  entryInfo >logins;// info
	QList< entryInfo >logoffs;// info
	QList<entryInfo >logClears;// info

	void output();
	static bool getClearInfo(QDomElement &root, entryInfo &info);

	static bool getEvtID(QDomElement &root, int &evtID);
	static bool getProcessName(QDomElement &root, QString &processName);
	static bool getUserName(QDomElement &root, QString &userName);
	static bool getHostName(QDomElement &root, QString &hostName);
	static bool getTime(QDomElement &root, QDateTime &time);
	static bool getLoginID(QDomElement &root, QString &loginID);

	static void getQueryResult(QStringList &qResults); // returns error info;
	static DWORD PrintResults(EVT_HANDLE hResults, QStringList &qResults);
	static DWORD PrintEvent(EVT_HANDLE hEvent, QString &str);

};


#endif